import org.jfree.chart.ChartMouseEvent;
import org.jfree.chart.ChartMouseListener;
import org.jfree.chart.entity.CategoryItemEntity;
import org.jfree.chart.entity.ChartEntity;
import org.jfree.chart.entity.PieSectionEntity;


public class MyChartMouseListener implements ChartMouseListener {
	
	private javax.swing.JLabel label;

	public MyChartMouseListener(javax.swing.JLabel label) {
		this.label = label;
	}

	public void chartMouseClicked(ChartMouseEvent event) {
		ChartEntity entity = event.getEntity();
		if(entity instanceof PieSectionEntity){
			String tag = ((PieSectionEntity)entity).getSectionKey().toString();
			label.setText("Tag " + tag + " clicked.");
		} else if(entity instanceof CategoryItemEntity){
			String tag = ((CategoryItemEntity)entity).getRowKey().toString();
			label.setText("Tag " + tag + " clicked.");
		}
	}

	public void chartMouseMoved(ChartMouseEvent event) {
	}

}
